﻿using System;
using System.Collections.Generic;
using System.Text;
using Common;

namespace LLFM.CAT.Config
{
    public enum PicSizeType
    {
        WH480X320 = 1,
        WH120X80 = 2,
        WH480X240 = 3,
        WH180X120 = 4,
        WH1200X800 = 5,
        WH240X160 = 6,
        WH640X310 = 7,
        WH150X100 = 8,
        WH90X60 = 9,
        WH700X0 = 10,
        WH730X350 = 11,
        WH920X350 = 12,
        WH210X140 = 13,
        WH728X350 = 14,
        WH920X0 = 15
    }

    public class UploadPicUrlManager
    {

        public static string GetPicUrlByRelUrl(string relateUrl, PicSizeType pt)
        {
            string url = UrlManager.GetNASServerUrl(DateTime.Now.Day, relateUrl);
            return GetPicUrlByAbsUrl(url, pt);
        }

        public static string GetPicUrlByAbsUrl(string orgUrl, PicSizeType pt)
        {
            int width = 0; int height = 0;
            switch (pt)
            {
                case PicSizeType.WH120X80: { width = 120; height = 80; break; }
                case PicSizeType.WH180X120: { width = 180; height = 120; break; }
                case PicSizeType.WH480X320: { width = 480; height = 320; break; }
                case PicSizeType.WH1200X800: { width = 1200; height = 800; break; }
                case PicSizeType.WH240X160: { width = 240; height = 160; break; }
                case PicSizeType.WH640X310: { width = 640; height = 310; break; }
                case PicSizeType.WH150X100: { width = 150; height = 100; break; }
                case PicSizeType.WH90X60: { width = 90; height = 60; break; }
                case PicSizeType.WH700X0: { width = 700; height = 0; break; }
                case PicSizeType.WH920X0: { width = 920; height = 0; break; }
                case PicSizeType.WH730X350: { width = 730; height = 350; break; }
                case PicSizeType.WH920X350: { width = 920; height = 350; break; }
                case PicSizeType.WH210X140: { width = 210; height = 140; break; }
                case PicSizeType.WH728X350: { width = 728; height = 350; break; }
                default: break;
            }
            string url = height > 0
                ? GDI.ResizeImage(orgUrl, height, width)
                : GDI.ResizeImage(orgUrl, width);
            return url;
        }
    }
}
